<template>
  <div class="app-container" v-loading="detailLoading">
    <el-card style="height: 100%; padding: 50px 194px; overflow-y: auto">
      <div class="title">
        {{ detailInfo.title }}
      </div>
      <div class="article-time">
        <!--        <div>作者：{{ detailInfo.author }}</div>-->
        <div v-if="detailInfo.publishTime">
          发布时间：{{ detailInfo.publishTime }}
        </div>
      </div>
      <div
        class="product-box"
        v-for="(item, index) in detailInfo.productList"
        :key="index"
      >
        <div class="product-box-l">
          <div class="product-box-image">
            <el-image
              style="width: 100px; height: 100px"
              :src="item.pic"
              :preview-src-list="[item.pic]"
            >
            </el-image>
          </div>
          <div class="product-box-name">
            <div>{{ item.name }}</div>
            <div>{{ JSON.parse(item.advantageData).join(",") }}</div>
          </div>
        </div>
        <div class="product-box-c">
          <div class="product-box-l-t">额度区间</div>
          <div class="product-box-l-b">
            {{ item.minQuota }}-{{ item.maxQuota }}万元
          </div>
        </div>
        <div class="product-box-c">
          <div class="product-box-l-t">年化利率</div>
          <div class="product-box-l-b">
            {{ item.minAnnualRate }}%-{{ item.maxAnnualRate }}%
          </div>
        </div>
        <div class="product-box-c">
          <div class="product-box-l-t">借款期限</div>
          <div class="product-box-l-b">{{ item.loanTerm }}期</div>
        </div>
        <div class="product-box-c" style="margin-right: 70px">
          <div class="product-box-l-t"></div>
          <div class="product-box-l-d" @click="detail(item)">
            查看详情
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </div>
      <div v-if="detailInfo.summary" style="margin-top: 20px">
        摘要：{{ detailInfo.summary }}
      </div>
      <div style="margin-top: 20px" v-html="detailInfo.content"></div>
    </el-card>
  </div>
</template>
<script>
import { getArticleInfo } from "@/api/article";
import { dictTypeFun } from "@/utils/dict";
export default {
  name: "detail",
  data() {
    return {
      detailInfo: {}
    };
  },
  created() {
    this.getInfo();
  },
  methods: {
    getInfo() {
      this.detailLoading = true;
      getArticleInfo(this.$route.query.id)
        .then(res => {
          this.detailInfo = res.data;
          this.detailLoading = false;
        })
        .finally(() => {
          this.detailLoading = false;
        });
    },
    detail(v) {
      if (v.publishStatus == 2) {
        return this.$message.error("该产品已下架");
      } else {
        let href = this.$router.resolve({
          name: "productDetail",
          query: {
            id: v.id
          }
        });
        window.open(href.href, "_blank");
      }
    }
  }
};
</script>

<style scoped lang="scss">
.app-container {
  height: calc(100vh - 50px);
  background-color: #f5f5f5;
  position: relative;
}

.title {
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  color: #222;
  font-weight: 500;
}
.article-time {
  margin-top: 20px;
  text-align: center;
  font-weight: 400;
  font-size: 16px;
  color: #999999;
  line-height: 22px;
  > div {
    margin-right: 60px;
    display: inline-block;
  }
}
.product-box {
  margin-top: 30px;
  display: flex;
  padding: 20px;
  justify-content: space-between;
  height: 140px;

  background: #ffffff;
  box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  .product-box-l {
    display: flex;
    height: 100px;
    .product-box-image {
      //margin-right: 20px;
    }
    .product-box-name {
      padding: 16px;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      > div {
        &:nth-child(1) {
          font-weight: 500;
          font-size: 18px;
          color: #222;
        }
        &:nth-child(2) {
          font-size: 16px;
          color: #666;
        }
      }
    }
  }
  .product-box-c {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    text-align: center;
    //margin-top: 30px;

    .product-box-l-t {
      font-weight: 400;
      font-size: 16px;
      color: #222;
      white-space: nowrap;
    }
    .product-box-l-b {
      font-size: 18px;
      font-weight: 500;
      color: #222;
      white-space: nowrap;
    }
    .product-box-l-d {
      color: #409eff;
      cursor: pointer;
      white-space: nowrap;
    }
  }
}
</style>
